// (c) Copyright 2013 Stephen Gold <sgold@sonic.net>
// Distributed under the terms of the GNU General Public License

/*
 This file is part of the Bats Game.

 The Bats Game is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by the
 Free Software Foundation, either version 3 of the License, or (at your
 option) any later version.

 The Bats Game is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.

 You should have received a copy of the GNU General Public License
 along with the Bats Game.  If not, see <http://www.gnu.org/licenses/>.
 */
package bats;

import com.beust.jcommander.Parameter;
import java.util.logging.Logger;

/**
 * Command-line parameters of the Bats Game.
 *
 * @author Stephen Gold <sgold@sonic.net>
 */
public class Parameters {
    // *************************************************************************
    // constants

    /**
     * message logger for this class
     */
    final private static Logger logger =
            Logger.getLogger(Parameters.class.getName());
    // *************************************************************************
    // fields
    /**
     * true means allow all unit types including the optional ones, false means
     * limit unit types to the basic set (bob and oto)
     */
    @Parameter(names = {"-a", "--all"},
            description = "allow all unit types")
    private boolean allUnits = false;
    /**
     * true means start the application in world-building mode
     */
    @Parameter(names = {"-b", "--build"},
            description = "start in world-building mode")
    private boolean buildMode = false;
    /**
     * true means disable shadows initially, false means start with shadows
     * enabled
     */
    @Parameter(names = {"-d", "--disable"},
            description = "start with shadows disabled")
    private boolean disableShadows = false;
    /**
     * true means start the HUD in the hidden state; false means start it in the
     * visible state
     */
    @Parameter(names = {"-H", "--hide"},
            description = "start with heads-up display hidden")
    private boolean hideHud = false;
    /**
     * true means start simulation mode in the paused state, false means start
     * it in the running state
     */
    @Parameter(names = {"-p", "--pause"},
            description = "start simulation in the paused state")
    private boolean paused = false;
    /**
     * true means start the application in pose mode
     */
    @Parameter(names = {"-P", "--pose"},
            description = "start in pose mode")
    private boolean poseMode = false;
    /**
     * true means configure using the standard Display Settings dialog box;
     * false means skip the dialog
     */
    @Parameter(names = {"-S", "--settings"},
            description = "configure using the Display Settings dialog")
    private boolean settingsDialog = false;
    /**
     * true means avoid using shaded/lit materials, false means allow shaded/lit
     * materials
     */
    @Parameter(names = {"-U", "--unshaded"},
            description = "avoid using shaded/lit materials")
    private boolean unshadedMaterials = false;
    /**
     * true means just display the usage message; false means run the
     * application
     */
    @Parameter(names = {"-h", "-u", "--help", "--usage"}, help = true,
            description = "display this usage message")
    private boolean usageOnly = false;
    /**
     * name of initial lighting preset for all scenes
     */
    @Parameter(names = {"-l", "--lighting"},
            description = "specify initial lighting preset")
    private String lightingPresetName = "morning";
    /**
     * name of the initial model for pose mode (bob/default/nan/none/oto/sinbad)
     */
    @Parameter(names = {"-M", "--model"},
            description = "specify initial model for pose mode")
    private String poseModelName = "default";
    /**
     * name of the initial scenario for build mode and simulation mode
     * (castle/default/empty/pose/test)
     */
    @Parameter(names = {"-s", "--scenario"},
            description = "specify initial scenario for build/sim modes")
    private String scenarioName = "default";
    // *************************************************************************
    // new methods exposed

    /**
     * Test the "all units" flag.
     *
     * @return true if all unit types are allowed, false if unit types are
     * limited to the basic set (bob and oto)
     */
    public boolean allUnits() {
        return allUnits;
    }

    /**
     * Test whether to start in world-building mode.
     *
     * @return true to start in world-building mode, otherwise false
     */
    boolean buildMode() {
        return buildMode;
    }

    /**
     * Test the parameters for consistency.
     *
     * @return true if consistent, false if inconsistent
     */
    boolean consistent() {
        if (buildMode && poseMode) {
            return false;
        }
        return true;
    }

    /**
     * Test the initial shadow status.
     *
     * @return true to enable shadows, false to disable them
     */
    public boolean enableShadows() {
        return !disableShadows;
    }

    /**
     * Read the name of the initial lighting preset for all scenes.
     *
     * @return preset name (not null)
     */
    String lightingPresetName() {
        assert lightingPresetName != null;
        return lightingPresetName;
    }

    /**
     * Test the initial simulation status for simulation mode.
     *
     * @return true to pause the simulation, false to run it
     */
    boolean paused() {
        return paused;
    }

    /**
     * Test whether to start in pose mode.
     *
     * @return true to start in pose mode, otherwise false
     */
    boolean poseMode() {
        return poseMode;
    }

    /**
     * Read the name of the initial model for pose mode.
     *
     * @return model name (not null)
     */
    public String poseModelName() {
        assert poseModelName != null;
        return poseModelName;
    }

    /**
     * Read the name of the initial scenario for build mode and simulation mode.
     *
     * @return scenario name (not null)
     */
    String scenarioName() {
        assert scenarioName != null;
        return scenarioName;
    }

    /**
     * Test the "Display Settings" dialog box status.
     *
     * @return true to open the dialog, false to skip it
     */
    boolean settingsDialog() {
        return settingsDialog;
    }

    /**
     * Test whether shaded/lit materials are enabled.
     *
     * @return true for shaded/lit materials, false for unshaded materials only
     */
    boolean shading() {
        return !unshadedMaterials;
    }

    /**
     * Test the initial HUD status.
     *
     * @return true to reveal the HUD, false to hide it
     */
    boolean showHud() {
        return !hideHud;
    }

    /**
     * Test whether the "usage only" option was specified.
     *
     * @return true to display usage and exit, false to execute normally
     */
    boolean usageOnly() {
        return usageOnly;
    }
}